package com.minimalist.common.entity.basic.vo.user;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.minimalist.common.config.swagger.SchemaEnum;
import com.minimalist.common.entity.basic.enums.StatusEnum;
import com.minimalist.common.entity.basic.enums.UserEnum;
import com.minimalist.common.entity.basic.vo.dept.DeptVO;
import com.minimalist.common.entity.basic.vo.perm.PermVO;
import com.minimalist.common.entity.basic.vo.post.PostVO;
import io.swagger.v3.oas.annotations.media.Schema;

import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
import java.util.Set;

/**
 * @author 11987
 */
@Schema(name = "用户实体")
public class UserInfoVO implements Serializable{

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(name = "userId", description = "用户ID", type = "string")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long userId;

    public Long getUserId(){
        return userId;
    }

    public void setUserId(Long userId){
        this.userId = userId;
    }

    @Schema(name = "username", description = "用户账号", type = "string")
    private String username;

    public String getUsername(){
        return username;
    }

    public void setUsername(String username){
        this.username = username;
    }

    /**
     * 用户密码
     */
    @JsonIgnore
    private String password;

    public String getPassword(){
        return password;
    }

    public void setPassword(String password){
        this.password = password;
    }

    @Schema(name = "nickname", description = "用户昵称", type = "string")
    private String nickname;

    public String getNickname(){
        return nickname;
    }

    public void setNickname(String nickname){
        this.nickname = nickname;
    }

    @Schema(name = "userRealName", description = "用户真实姓名", type = "string")
    private String userRealName;

    public String getUserRealName(){
        return userRealName;
    }

    public void setUserRealName(String userRealName){
        this.userRealName = userRealName;
    }

    @Schema(name = "email", description = "用户邮箱", type = "string")
    private String email;

    public String getEmail(){
        return email;
    }

    public void setEmail(String email){
        this.email = email;
    }

    @Schema(name = "mobile", description = "手机号码", type = "string")
    private String mobile;

    public String getMobile(){
        return mobile;
    }

    public void setMobile(String mobile){
        this.mobile = mobile;
    }

    @SchemaEnum(implementation = UserEnum.UserSex.class)
    @Schema(name = "userSex", description = "用户性别", type = "integer")
    private Integer userSex;

    public Integer getUserSex(){
        return userSex;
    }

    public void setUserSex(Integer userSex){
        this.userSex = userSex;
    }

    @Schema(name = "avatar", description = "用户头像base64编码", type = "string")
    private String avatar;

    public String getAvatar(){
        return avatar;
    }

    public void setAvatar(String avatar){
        this.avatar = avatar;
    }

    @Schema(name = "userType", description = "用户类型", type = "integer")
    private Integer userType;

    public Integer getUserType(){
        return userType;
    }

    public void setUserType(Integer userType){
        this.userType = userType;
    }

    @Schema(name = "remark", description = "备注", type = "string")
    private String remark;

    public String getRemark(){
        return remark;
    }

    public void setRemark(String remark){
        this.remark = remark;
    }

    @SchemaEnum(implementation = StatusEnum.class)
    @Schema(name = "status", description = "状态", type = "integer")
    private Integer status;

    public Integer getStatus(){
        return status;
    }

    public void setStatus(Integer status){
        this.status = status;
    }

    @Schema(name = "tenantId", description = "租户编号", type = "string")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long tenantId;

    public Long getTenantId(){
        return tenantId;
    }

    public void setTenantId(Long tenantId){
        this.tenantId = tenantId;
    }

    private Long deptId;

    public Long getDeptId(){
        return deptId;
    }

    public void setDeptId(Long deptId){
        this.deptId = deptId;
    }

    private Set<Long> postIds;

    public Set<Long> getPostIds(){
        return postIds;
    }

    public void setPostIds(Set<Long> postIds){
        this.postIds = postIds;
    }

    @Schema(name = "roleIds", description = "角色ID列表", type = "array")
    @JsonSerialize(using = ToStringSerializer.class)
    private Set<Long> roleIds;

    public Set<Long> getRoleIds(){
        return roleIds;
    }

    public void setRoleIds(Set<Long> roleIds){
        this.roleIds = roleIds;
    }

    @Schema(name = "perms", description = "用户权限标识符", type = "array")
    private Set<String> perms;

    public Set<String> getPerms(){
        return perms;
    }

    public void setPerms(Set<String> perms){
        this.perms = perms;
    }

    private Set<String> roles;

    public Set<String> getRoles(){
        return roles;
    }

    public void setRoles(Set<String> roles){
        this.roles = roles;
    }

    @Schema(name = "dept", description = "部门信息", type = "object")
    private DeptVO dept;

    public DeptVO getDept(){
        return dept;
    }

    public void setDept(DeptVO dept){
        this.dept = dept;
    }

    @Schema(name = "deptList", description = "用户所属部门信息", type = "array")
    private List<DeptVO> deptList;

    public List<DeptVO> getDeptList(){
        return deptList;
    }

    public void setDeptList(List<DeptVO> deptList){
        this.deptList = deptList;
    }

    @Schema(name = "postList", description = "用户所属岗位信息", type = "array")
    private List<PostVO> postList;

    public List<PostVO> getPostList(){
        return postList;
    }

    public void setPostList(List<PostVO> postList){
        this.postList = postList;
    }

    @Schema(name = "permList", description = "用户权限信息", type = "array")
    private List<PermVO> permList;

    public List<PermVO> getPermList(){
        return permList;
    }

    public void setPermList(List<PermVO> permList){
        this.permList = permList;
    }

    @Schema(name = "menus", description = "用户菜单信息", type = "array")
    private List<PermVO> menus;

    public List<PermVO> getMenus(){
        return menus;
    }

    public void setMenus(List<PermVO> menus){
        this.menus = menus;
    }

    @Schema(name = "createTime", description = "创建时间", type = "string")
    private String createTime;

    public String getCreateTime(){
        return createTime;
    }

    public void setCreateTime(String createTime){
        this.createTime = createTime;
    }

    @Override
    public boolean equals(Object o){
        if (this == o){
            return true;
        }
        if (o == null || getClass() != o.getClass()){
            return false;
        }
        UserInfoVO that = (UserInfoVO) o;
        return Objects.equals(userId, that.userId) &&
                Objects.equals(username, that.username) &&
                Objects.equals(password, that.password) &&
                Objects.equals(nickname, that.nickname) &&
                Objects.equals(userRealName, that.userRealName) &&
                Objects.equals(email, that.email) &&
                Objects.equals(mobile, that.mobile) &&
                Objects.equals(userSex, that.userSex) &&
                Objects.equals(avatar, that.avatar) &&
                Objects.equals(userType, that.userType) &&
                Objects.equals(remark, that.remark) &&
                Objects.equals(status, that.status) &&
                Objects.equals(deptId, that.deptId) &&
                Objects.equals(postIds, that.postIds) &&
                Objects.equals(roleIds, that.roleIds) &&
                Objects.equals(perms, that.perms) &&
                Objects.equals(roles, that.roles) &&
                Objects.equals(dept, that.dept) &&
                Objects.equals(deptList, that.deptList) &&
                Objects.equals(postList, that.postList) &&
                Objects.equals(permList, that.permList) &&
                Objects.equals(menus, that.menus) &&
                Objects.equals(createTime, that.createTime);
    }

    @Override
    public int hashCode(){
        return Objects.hash(userId, username, password, nickname, userRealName, email, mobile, userSex, avatar, userType, remark, status, deptId, postIds, roleIds, perms, roles, dept, deptList, postList, permList, menus, createTime);
    }

    @Override
    public String toString(){
        return "UserInfoVO{" +
                "userId=" + userId +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", nickname='" + nickname + '\'' +
                ", userRealName='" + userRealName + '\'' +
                ", email='" + email + '\'' +
                ", mobile='" + mobile + '\'' +
                ", sex=" + userSex +
                ", avatar='" + avatar + '\'' +
                ", userType=" + userType +
                ", remark='" + remark + '\'' +
                ", status=" + status +
                ", deptId=" + deptId +
                ", postIds=" + postIds +
                ", roleIds=" + roleIds +
                ", perms=" + perms +
                ", roles=" + roles +
                ", dept=" + dept +
                ", deptList=" + deptList +
                ", postList=" + postList +
                ", permList=" + permList +
                ", menus=" + menus +
                ", createTime='" + createTime + '\'' +
                '}';
    }
}
